aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/invoice/[id]/+layout.server.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-31 09:34:16 -0700
committerAdam Soltys <[email protected]>2024-10-31 09:34:16 -0700
commit243abb0a3d29e8e34e263eec843488e3bdb468a4 (patch)
treebe55931ba0f3c110c3001f56a5339cb63e78b761 /src/routes/(app)/invoice/[id]/+layout.server.ts
parent4742e72ec25823ceeea7848fb2e1f868bed7f472 (diff)
downloadcoinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.tar.gz
coinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.zip
biome
Diffstat (limited to 'src/routes/(app)/invoice/[id]/+layout.server.ts')
-rw-r--r--src/routes/(app)/invoice/[id]/+layout.server.ts56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts
index bad43c97..a844b928 100644
--- a/src/routes/(app)/invoice/[id]/+layout.server.ts
+++ b/src/routes/(app)/invoice/[id]/+layout.server.ts
@@ -3,38 +3,38 @@ import { get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function load({ cookies, depends, params, url, parent }) {
- depends("app:invoice");
+ depends("app:invoice");
- let token = cookies.get("token");
- let { subject, user } = await parent();
- let { id } = params;
- let invoice;
+ const token = cookies.get("token");
+ let { subject, user } = await parent();
+ const { id } = params;
+ let invoice;
- if (id) {
- invoice = await get(`/invoice/${id}`);
- let options = !!url.searchParams.get("options");
+ if (id) {
+ invoice = await get(`/invoice/${id}`);
+ const options = !!url.searchParams.get("options");
- if (
- user &&
- invoice.uid !== user.id &&
- !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
- !options
- ) {
- redirect(307, `/send/invoice/${id}`);
- }
+ if (
+ user &&
+ invoice.uid !== user.id &&
+ !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
+ !options
+ ) {
+ redirect(307, `/send/invoice/${id}`);
+ }
- let { amount, pending, received } = invoice;
- amount = parseInt(amount);
- subject = user || invoice.user;
+ let { amount, pending, received } = invoice;
+ amount = parseInt(amount);
+ subject = user || invoice.user;
- let paid =
- (!amount && (pending || received)) ||
- (amount > 0 && (pending >= amount || received >= amount));
- if (paid && !url.pathname.endsWith("paid")) {
- redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : ""));
- }
- }
+ const paid =
+ (!amount && (pending || received)) ||
+ (amount > 0 && (pending >= amount || received >= amount));
+ if (paid && !url.pathname.endsWith("paid")) {
+ redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : ""));
+ }
+ }
- let src = Qr.drawImg(invoice?.text || "", { size: 500 });
- return { id, invoice, subject, src, user, token };
+ const src = Qr.drawImg(invoice?.text || "", { size: 500 });
+ return { id, invoice, subject, src, user, token };
}